package com.baby.topics;

import com.baby.utils.ConnectionUtil;
import com.rabbitmq.client.*;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Consumer1 {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = ConnectionUtil.getConnection();
        Channel channel = connection.createChannel();

        channel.queueDeclare("topics_consumer1",true,false,false,null );

        channel.queueBind("topics_consumer1","topics_exchange","*.orange.*");
        Consumer consumer=new DefaultConsumer(channel){
            @Override
            public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
                System.out.println("消费者1获取信息"+new String(body));
            }
        };

        channel.basicConsume("topics_consumer1",true,consumer);
    }
}
